<template>
  <div id='app'>
    <search></search>
    <swiper class="swiper"></swiper>
    <navList /> 
    <!-- 秒杀 -->
    <!-- <confine /> -->
    <!-- <feature /> -->
    <hot />
    <item />
    <floor :brandName="'疫情防护'" :brandTitle="'抵抗疫情-从自我做起!'"  :dataList="footList"/>
    <user-like :title="'猜你喜欢'" />
    <footBox class="footBox" />
    <top-wrap />
    <navFooter />
    
  </div>
</template>
<script>
import search from "../components/home/search";
// import banar from "../components/home/banar";
import navList from "../components/home/nav_list";
import confine from "../components/home/confine";
// import feature from "../components/home/feature";
import hot from "../components/home/hot";
import floor from "../components/home/floor";
import userLike from "../components/home/userLike";
import footBox from "../components/public/footbox";
import topWrap from "../components/public/top-wrap";
import navFooter from "../components/public/navFooter";
// import ajax from "../func/fetch";
import swiper from "../components/home/swiper";
import item from "../components/home/item";
import {MP} from '.././func/baiduMap.js'
export default {
  name: "home",
  components: {
    search,
    swiper,
    // banar,
    navList,
    confine,
    // feature,
    hot,
    floor,
    userLike,
    footBox,
    topWrap,
    navFooter,
    // newBanar
    item
  },
  data(){
    return {
      footList: []
    }
  },
  methods: {
     async getFootList(){
       const res = await this.$http.get(`search.do?page=${1}&size=${6}&category=疫情防护`)
       console.log(res)
       this.footList = res.data.rows
     }
  },
  created() {
    this.getFootList()
     //定位
     this.$nextTick(function () {
                   var th = this
                   // 创建Map实例
                    MP(th.ak).then(BMap => {
                          //在此调用api
                   // 初始化地图,设置中心点坐标，
                   var point = new BMap.Point(121.160724,31.173277); 
                  //定位
                   var geolocation = new BMap.Geolocation();
                   geolocation.getCurrentPosition(function(r){console.log(r.point)
                    var mk = new BMap.Marker(r.point);
                    //alert('您的位置：'+r.point.lng+','+r.point.lat);
                    var point = new BMap.Point(r.point.lng,r.point.lat);//用所定位的经纬度查找所在地省市街道等信息
                    var gc = new BMap.Geocoder();
                    gc.getLocation(point, function(rs){
                       var addComp = rs.addressComponents; console.log(addComp.city);//地址信息
                         th.$store.commit('saveCurrentCity',addComp.city)
                     })
                  },{enableHighAccuracy: true})


                    })

                   
            })
        },
  
};
</script>

<style scoped lang='scss'>

.swiper {
	padding-top: 3.5rem;
}
.footBox {
  padding-bottom: 65px;
}
</style>